package webdev.views;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
import dev.danang.R;

public class CircleView extends View {

	private int mWidth;
	private int mHeight;
	private Context mContext;
	private Paint mPaint;
	private int mStrokeWidth;
	private int mRho;

	public CircleView(Context context, AttributeSet attrs) {
		super(context, attrs);
		mContext = context;
		mPaint = new Paint();
		mWidth = context.getResources().getDimensionPixelOffset(R.dimen.cirle_view_size);
		mHeight = context.getResources().getDimensionPixelOffset(R.dimen.cirle_view_size);
		mStrokeWidth = mContext.getResources().getDimensionPixelOffset(R.dimen.cirle_view_stroke);
		mRho = mContext.getResources().getDimensionPixelOffset(R.dimen.cirle_view_rho) / 2;
	}

	public CircleView(Context context) {
		super(context);
		mContext = context;
		mPaint = new Paint();
		mWidth = context.getResources().getDimensionPixelOffset(R.dimen.cirle_view_size);
		mHeight = context.getResources().getDimensionPixelOffset(R.dimen.cirle_view_size);
	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
	
		mPaint.setColor(mContext.getResources().getColor(R.color.color_circle_action_activity));
		mPaint.setStrokeWidth(mStrokeWidth);
		mPaint.setStyle(Paint.Style.STROKE);
		
		canvas.drawCircle(mWidth / 2, mHeight / 2, mRho, mPaint);
	}
}
